﻿namespace QLBanHang.UC
{
    using ConfigDatabase.Class;
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraTab;
    using Access.Duoc;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class ucd_thongso : XtraUserControl
    {
        private ConnectDatabase _condata;
        private DThongSo _tsduoc;
        private SimpleButton btnketthuc;
        private SimpleButton btnluu;
        private CheckBox chk1;
        private CheckBox chkxuat_canhbaohetdate;
        private IContainer components = null;
        private GroupControl groupControl1;
        private GroupControl groupControl2;
        private Label label1;
        private Label label2;
        private Label label25;
        private Label label3;
        private Label label4;
        private Label label5;
        private NumericUpDown numapgia_ptgiadv;
        private NumericUpDown numapgia_ptgiathuong;
        private NumericUpDown numxuat_songaycanhbaohetdate;
        private PanelControl pnlgiaban;
        private RadioButton rdbapgia_theogianhaplonnhat;
        private RadioButton rdbapgia_theophieunhap;
        private RadioButton rdbxuat_nhaptruocxuattruoc;

        public ucd_thongso()
        {
            this.InitializeComponent();
        }

        private void btnketthuc_Click(object sender, EventArgs e)
        {
            try
            {
                XtraTabPage parent = (XtraTabPage) base.Parent;
                XtraTabControl control = (XtraTabControl) parent.Parent;
                control.TabPages.Remove(parent);
            }
            catch
            {
                try
                {
                    XtraUserControl control2 = (XtraUserControl) base.Parent;
                    control2.Controls.Remove(this);
                }
                catch
                {
                    ((Form) base.Parent).Close();
                }
            }
        }

        private void btnluu_Click(object sender, EventArgs e)
        {
            this.f_thongso_save();
            MessageBox.Show("Lưu th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK);
        }

        private void chk1_CheckedChanged(object sender, EventArgs e)
        {
            this.pnlgiaban.Enabled = !this.chk1.Checked;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void f_thongso_load()
        {
            this.rdbxuat_nhaptruocxuattruoc.Checked = this._tsduoc.pXuat_NhapTruocXuatTruoc;
            this.numxuat_songaycanhbaohetdate.Value = Convert.ToDecimal(this._tsduoc.pXuat_CanhBaoHetDate_SoNgay);
            this.rdbapgia_theophieunhap.Checked = this._tsduoc.pApGia_TheoGiaNhap;
            this.rdbapgia_theogianhaplonnhat.Checked = this._tsduoc.pApGia_TheoGiaNhapMax;
            this.numapgia_ptgiadv.Value = Convert.ToDecimal(this._tsduoc.pApGia_PTGiaDichVu);
            this.numapgia_ptgiathuong.Value = Convert.ToDecimal(this._tsduoc.pApGia_PTGiaThuong);
            this.chk1.Checked = this._tsduoc.pApGia_TheoDanhMucGia;
        }

        private void f_thongso_save()
        {
            this._tsduoc.pXuat_NhapTruocXuatTruoc = this.rdbxuat_nhaptruocxuattruoc.Checked;
            this._tsduoc.pXuat_CanhBaoHetDate_SoNgay = Convert.ToInt16(this.numxuat_songaycanhbaohetdate.Value);
            this._tsduoc.pApGia_TheoGiaNhap = this.rdbapgia_theophieunhap.Checked;
            this._tsduoc.pApGia_TheoGiaNhapMax = this.rdbapgia_theogianhaplonnhat.Checked;
            this._tsduoc.pApGia_PTGiaDichVu = Convert.ToInt16(this.numapgia_ptgiadv.Value);
            this._tsduoc.pApGia_PTGiaThuong = Convert.ToInt16(this.numapgia_ptgiathuong.Value);
            this._tsduoc.pApGia_TheoDanhMucGia = this.chk1.Checked;
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ucd_thongso));
            this.btnketthuc = new DevExpress.XtraEditors.SimpleButton();
            this.btnluu = new DevExpress.XtraEditors.SimpleButton();
            this.rdbapgia_theophieunhap = new System.Windows.Forms.RadioButton();
            this.rdbapgia_theogianhaplonnhat = new System.Windows.Forms.RadioButton();
            this.label1 = new System.Windows.Forms.Label();
            this.numapgia_ptgiathuong = new System.Windows.Forms.NumericUpDown();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.numapgia_ptgiadv = new System.Windows.Forms.NumericUpDown();
            this.groupControl1 = new DevExpress.XtraEditors.GroupControl();
            this.chkxuat_canhbaohetdate = new System.Windows.Forms.CheckBox();
            this.rdbxuat_nhaptruocxuattruoc = new System.Windows.Forms.RadioButton();
            this.label5 = new System.Windows.Forms.Label();
            this.numxuat_songaycanhbaohetdate = new System.Windows.Forms.NumericUpDown();
            this.groupControl2 = new DevExpress.XtraEditors.GroupControl();
            this.pnlgiaban = new DevExpress.XtraEditors.PanelControl();
            this.chk1 = new System.Windows.Forms.CheckBox();
            this.label25 = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.numapgia_ptgiathuong)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.numapgia_ptgiadv)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
            this.groupControl1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.numxuat_songaycanhbaohetdate)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.groupControl2)).BeginInit();
            this.groupControl2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnlgiaban)).BeginInit();
            this.pnlgiaban.SuspendLayout();
            this.SuspendLayout();
            // 
            // btnketthuc
            // 
            this.btnketthuc.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
            this.btnketthuc.Appearance.Options.UseTextOptions = true;
            this.btnketthuc.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
            this.btnketthuc.Image = ((System.Drawing.Image)(resources.GetObject("btnketthuc.Image")));
            this.btnketthuc.Location = new System.Drawing.Point(275, 241);
            this.btnketthuc.Name = "btnketthuc";
            this.btnketthuc.Size = new System.Drawing.Size(79, 23);
            this.btnketthuc.TabIndex = 3;
            this.btnketthuc.Text = " &Kết thúc";
            this.btnketthuc.Click += new System.EventHandler(this.btnketthuc_Click);
            // 
            // btnluu
            // 
            this.btnluu.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
            this.btnluu.Appearance.Options.UseTextOptions = true;
            this.btnluu.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
            this.btnluu.Image = global::QLBanHang.Resources.Reso.imgsave;
            this.btnluu.Location = new System.Drawing.Point(208, 241);
            this.btnluu.Name = "btnluu";
            this.btnluu.Size = new System.Drawing.Size(63, 23);
            this.btnluu.TabIndex = 2;
            this.btnluu.Text = " &Lưu";
            this.btnluu.Click += new System.EventHandler(this.btnluu_Click);
            // 
            // rdbapgia_theophieunhap
            // 
            this.rdbapgia_theophieunhap.AutoSize = true;
            this.rdbapgia_theophieunhap.Checked = true;
            this.rdbapgia_theophieunhap.Font = new System.Drawing.Font("Tahoma", 10F);
            this.rdbapgia_theophieunhap.Location = new System.Drawing.Point(5, 5);
            this.rdbapgia_theophieunhap.Name = "rdbapgia_theophieunhap";
            this.rdbapgia_theophieunhap.Size = new System.Drawing.Size(167, 21);
            this.rdbapgia_theophieunhap.TabIndex = 0;
            this.rdbapgia_theophieunhap.TabStop = true;
            this.rdbapgia_theophieunhap.Text = "Áp giá theo phiếu nhập";
            this.rdbapgia_theophieunhap.UseVisualStyleBackColor = true;
            // 
            // rdbapgia_theogianhaplonnhat
            // 
            this.rdbapgia_theogianhaplonnhat.AutoSize = true;
            this.rdbapgia_theogianhaplonnhat.Font = new System.Drawing.Font("Tahoma", 10F);
            this.rdbapgia_theogianhaplonnhat.Location = new System.Drawing.Point(5, 32);
            this.rdbapgia_theogianhaplonnhat.Name = "rdbapgia_theogianhaplonnhat";
            this.rdbapgia_theogianhaplonnhat.Size = new System.Drawing.Size(184, 21);
            this.rdbapgia_theogianhaplonnhat.TabIndex = 1;
            this.rdbapgia_theogianhaplonnhat.Text = "Áp theo giá nhập lớn nhất";
            this.rdbapgia_theogianhaplonnhat.UseVisualStyleBackColor = true;
            // 
            // label1
            // 
            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(163)));
            this.label1.Location = new System.Drawing.Point(261, 17);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(25, 26);
            this.label1.TabIndex = 23;
            this.label1.Text = "%";
            // 
            // numapgia_ptgiathuong
            // 
            this.numapgia_ptgiathuong.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(163)));
            this.numapgia_ptgiathuong.Location = new System.Drawing.Point(212, 16);
            this.numapgia_ptgiathuong.Name = "numapgia_ptgiathuong";
            this.numapgia_ptgiathuong.Size = new System.Drawing.Size(51, 26);
            this.numapgia_ptgiathuong.TabIndex = 2;
            // 
            // label2
            // 
            this.label2.Font = new System.Drawing.Font("Tahoma", 12F);
            this.label2.Location = new System.Drawing.Point(422, 16);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(25, 26);
            this.label2.TabIndex = 23;
            this.label2.Text = "%";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label3
            // 
            this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(163)));
            this.label3.Location = new System.Drawing.Point(281, 16);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(106, 26);
            this.label3.TabIndex = 23;
            this.label3.Text = "Giá thường";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label4
            // 
            this.label4.Font = new System.Drawing.Font("Tahoma", 12F);
            this.label4.Location = new System.Drawing.Point(443, 16);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(107, 26);
            this.label4.TabIndex = 23;
            this.label4.Text = "Giá dịch vụ";
            this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // numapgia_ptgiadv
            // 
            this.numapgia_ptgiadv.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(163)));
            this.numapgia_ptgiadv.Location = new System.Drawing.Point(380, 16);
            this.numapgia_ptgiadv.Name = "numapgia_ptgiadv";
            this.numapgia_ptgiadv.Size = new System.Drawing.Size(44, 26);
            this.numapgia_ptgiadv.TabIndex = 3;
            // 
            // groupControl1
            // 
            this.groupControl1.AppearanceCaption.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
            this.groupControl1.AppearanceCaption.Options.UseFont = true;
            this.groupControl1.Controls.Add(this.chkxuat_canhbaohetdate);
            this.groupControl1.Controls.Add(this.rdbxuat_nhaptruocxuattruoc);
            this.groupControl1.Controls.Add(this.label5);
            this.groupControl1.Controls.Add(this.numxuat_songaycanhbaohetdate);
            this.groupControl1.Location = new System.Drawing.Point(0, 46);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Size = new System.Drawing.Size(593, 80);
            this.groupControl1.TabIndex = 0;
            this.groupControl1.Text = "Xuất kho";
            // 
            // chkxuat_canhbaohetdate
            // 
            this.chkxuat_canhbaohetdate.AutoSize = true;
            this.chkxuat_canhbaohetdate.Font = new System.Drawing.Font("Tahoma", 10F);
            this.chkxuat_canhbaohetdate.Location = new System.Drawing.Point(307, 28);
            this.chkxuat_canhbaohetdate.Name = "chkxuat_canhbaohetdate";
            this.chkxuat_canhbaohetdate.Size = new System.Drawing.Size(168, 21);
            this.chkxuat_canhbaohetdate.TabIndex = 1;
            this.chkxuat_canhbaohetdate.Text = "Cảnh báo sắp hết Date";
            this.chkxuat_canhbaohetdate.UseVisualStyleBackColor = true;
            this.chkxuat_canhbaohetdate.Visible = false;
            // 
            // rdbxuat_nhaptruocxuattruoc
            // 
            this.rdbxuat_nhaptruocxuattruoc.AutoSize = true;
            this.rdbxuat_nhaptruocxuattruoc.Checked = true;
            this.rdbxuat_nhaptruocxuattruoc.Font = new System.Drawing.Font("Tahoma", 10F);
            this.rdbxuat_nhaptruocxuattruoc.Location = new System.Drawing.Point(17, 27);
            this.rdbxuat_nhaptruocxuattruoc.Name = "rdbxuat_nhaptruocxuattruoc";
            this.rdbxuat_nhaptruocxuattruoc.Size = new System.Drawing.Size(166, 21);
            this.rdbxuat_nhaptruocxuattruoc.TabIndex = 0;
            this.rdbxuat_nhaptruocxuattruoc.TabStop = true;
            this.rdbxuat_nhaptruocxuattruoc.Text = "Nhập trước xuất trước";
            this.rdbxuat_nhaptruocxuattruoc.UseVisualStyleBackColor = true;
            // 
            // label5
            // 
            this.label5.Font = new System.Drawing.Font("Tahoma", 10F);
            this.label5.Location = new System.Drawing.Point(520, 27);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(50, 21);
            this.label5.TabIndex = 23;
            this.label5.Text = "tháng";
            this.label5.Visible = false;
            // 
            // numxuat_songaycanhbaohetdate
            // 
            this.numxuat_songaycanhbaohetdate.Location = new System.Drawing.Point(481, 27);
            this.numxuat_songaycanhbaohetdate.Name = "numxuat_songaycanhbaohetdate";
            this.numxuat_songaycanhbaohetdate.Size = new System.Drawing.Size(39, 21);
            this.numxuat_songaycanhbaohetdate.TabIndex = 2;
            this.numxuat_songaycanhbaohetdate.Visible = false;
            // 
            // groupControl2
            // 
            this.groupControl2.AppearanceCaption.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
            this.groupControl2.AppearanceCaption.Options.UseFont = true;
            this.groupControl2.Controls.Add(this.pnlgiaban);
            this.groupControl2.Controls.Add(this.chk1);
            this.groupControl2.Location = new System.Drawing.Point(0, 126);
            this.groupControl2.Name = "groupControl2";
            this.groupControl2.Size = new System.Drawing.Size(593, 111);
            this.groupControl2.TabIndex = 1;
            this.groupControl2.Text = "Áp giá bán";
            // 
            // pnlgiaban
            // 
            this.pnlgiaban.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.pnlgiaban.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Flat;
            this.pnlgiaban.Controls.Add(this.rdbapgia_theophieunhap);
            this.pnlgiaban.Controls.Add(this.rdbapgia_theogianhaplonnhat);
            this.pnlgiaban.Controls.Add(this.label2);
            this.pnlgiaban.Controls.Add(this.numapgia_ptgiadv);
            this.pnlgiaban.Controls.Add(this.label4);
            this.pnlgiaban.Controls.Add(this.label3);
            this.pnlgiaban.Controls.Add(this.numapgia_ptgiathuong);
            this.pnlgiaban.Controls.Add(this.label1);
            this.pnlgiaban.Location = new System.Drawing.Point(12, 48);
            this.pnlgiaban.Name = "pnlgiaban";
            this.pnlgiaban.Size = new System.Drawing.Size(576, 60);
            this.pnlgiaban.TabIndex = 27;
            // 
            // chk1
            // 
            this.chk1.AutoSize = true;
            this.chk1.Font = new System.Drawing.Font("Tahoma", 10F);
            this.chk1.Location = new System.Drawing.Point(13, 26);
            this.chk1.Name = "chk1";
            this.chk1.Size = new System.Drawing.Size(226, 21);
            this.chk1.TabIndex = 1;
            this.chk1.Text = "1. Áp giá theo danh mục giá bán";
            this.chk1.UseVisualStyleBackColor = true;
            this.chk1.CheckedChanged += new System.EventHandler(this.chk1_CheckedChanged);
            // 
            // label25
            // 
            this.label25.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.label25.BackColor = System.Drawing.Color.Green;
            this.label25.Font = new System.Drawing.Font("Tahoma", 16F);
            this.label25.ForeColor = System.Drawing.Color.White;
            this.label25.Location = new System.Drawing.Point(0, 0);
            this.label25.Name = "label25";
            this.label25.Size = new System.Drawing.Size(593, 45);
            this.label25.TabIndex = 26;
            this.label25.Text = "THÔNG SỐ";
            this.label25.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // ucd_thongso
            // 
            this.Controls.Add(this.label25);
            this.Controls.Add(this.groupControl2);
            this.Controls.Add(this.groupControl1);
            this.Controls.Add(this.btnluu);
            this.Controls.Add(this.btnketthuc);
            this.LookAndFeel.UseWindowsXPTheme = true;
            this.Name = "ucd_thongso";
            this.Size = new System.Drawing.Size(593, 267);
            this.Load += new System.EventHandler(this.UCphanquyensudung_Load);
            ((System.ComponentModel.ISupportInitialize)(this.numapgia_ptgiathuong)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.numapgia_ptgiadv)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.groupControl1)).EndInit();
            this.groupControl1.ResumeLayout(false);
            this.groupControl1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.numxuat_songaycanhbaohetdate)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.groupControl2)).EndInit();
            this.groupControl2.ResumeLayout(false);
            this.groupControl2.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnlgiaban)).EndInit();
            this.pnlgiaban.ResumeLayout(false);
            this.pnlgiaban.PerformLayout();
            this.ResumeLayout(false);

        }

        private void UCphanquyensudung_Load(object sender, EventArgs e)
        {
            if (this._condata == null)
            {
                this._condata = new ConnectDatabase();
            }
            this._tsduoc = new DThongSo(this._condata);
            this.f_thongso_load();
        }

        public ConnectDatabase pCondata
        {
            get
            {
                return this._condata;
            }
            set
            {
                this._condata = value;
            }
        }
    }
}

